#import <Cocoa/Cocoa.h>
#include <vector>

#import "sbrush_instrument.h"

@interface InstrumentView : NSView {
	/* For Instrument, consider double buffered approach. We can handle copies, but
	 * no memory allocations or drawing commands on the instrument callback.
	 * Otherwise we run the risk of slowing things down.  To avoid this have two
	 * buffers for instrument states.  Use a vector of InstrumentState pointers
	 * and have a separate counter keeping track of how many of those are valid.
	 * (add to vector as necessary).  Have two of these vectors and swap them 
	 * when drawing.  Similar to other double-buffered methods for window
	 * paintint */
	std::vector<sbrush::InstrumentState*>* _stateBuffer1;
	std::vector<sbrush::InstrumentState*>* _stateBuffer2;
	std::vector<sbrush::InstrumentState*>* _drawBuffer;
	std::vector<sbrush::InstrumentState*>* _loadBuffer;
	std::vector<const sbrush::InstrumentState*>* _returnBuffer;
	unsigned _drawBufferSize;
	unsigned _loadBufferSize;
	
	NSLock* _bufferSwapLock;
}

- (void) clear;
- (void) update:(const sbrush::InstrumentState*)state;
- (const std::vector<const sbrush::InstrumentState*>*) acquireLatestStates;
- (void) startCountdown;
- (void) displayCountdown:(unsigned)count;
- (void) finishCountdown;
- (void) startDrawing;
- (void) stopDrawing;
@end
